package cn.globalph.housekeeper.data

import android.content.Context
import cn.globalph.housekeeper.data.model.LoginModel
import cn.globalph.housekeeper.data.model.Profile
import cn.globalph.housekeeper.data.source.UserInfoPreferenceManager

class TokenStorage {
    companion object{
        var token:String? = null
        var profile: Profile? = null

        fun setUserData(context: Context,data:LoginModel){
            token = data.token
            profile = data.profile
            UserInfoPreferenceManager.updateInfo(context,data)
        }

        fun loadData(context: Context){
            token = UserInfoPreferenceManager.getToken(context)
            profile = UserInfoPreferenceManager.getProfile(context)
        }

        fun exitLogin(context: Context){
            token = null
            profile = null
            UserInfoPreferenceManager.clearLoginData(context)
        }
    }
}